package com.linshengjian.snowball.payment;

import com.linshengjian.snowball.payment.handler.AlipayHandlerImpl;
import com.linshengjian.snowball.payment.handler.WxpayHandlerImpl;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.HashMap;
import java.util.Map;

@Setter
@Getter
@ConfigurationProperties(prefix = "snowball.payment")
public class PaymentProperties {

    public static class WxPay{
        private String appId;
        private String mchId;
        private String mchKey;
        private String subAppId;
        private String subMchId;
        private String keyPath;

        public String getAppId() {
            return appId;
        }

        public void setAppId(String appId) {
            this.appId = appId;
        }

        public String getMchId() {
            return mchId;
        }

        public void setMchId(String mchId) {
            this.mchId = mchId;
        }

        public String getMchKey() {
            return mchKey;
        }

        public void setMchKey(String mchKey) {
            this.mchKey = mchKey;
        }

        public String getSubAppId() {
            return subAppId;
        }

        public void setSubAppId(String subAppId) {
            this.subAppId = subAppId;
        }

        public String getSubMchId() {
            return subMchId;
        }

        public void setSubMchId(String subMchId) {
            this.subMchId = subMchId;
        }

        public String getKeyPath() {
            return keyPath;
        }

        public void setKeyPath(String keyPath) {
            this.keyPath = keyPath;
        }
    }
    public static class AliPay{
        private String serverUrl = "https://openapi.alipay.com/gateway.do";
        private String appId;
        private String privateKey;
        private String publicKey;

        public String getServerUrl() {
            return serverUrl;
        }

        public void setServerUrl(String serverUrl) {
            this.serverUrl = serverUrl;
        }

        public String getAppId() {
            return appId;
        }

        public void setAppId(String appId) {
            this.appId = appId;
        }

        public String getPrivateKey() {
            return privateKey;
        }

        public void setPrivateKey(String privateKey) {
            this.privateKey = privateKey;
        }

        public String getPublicKey() {
            return publicKey;
        }

        public void setPublicKey(String publicKey) {
            this.publicKey = publicKey;
        }
    }

    private String callbackDomainName;
    private String callbackUrl = "/callback";
    private Map<String, Class<? extends IPaymentHandler>> type = new HashMap<>();
    private AliPay aliPay = new AliPay();
    private WxPay wxPay = new WxPay();

    public PaymentProperties() {
        this.type.put("aliPay", AlipayHandlerImpl.class);
        this.type.put("wxPay", WxpayHandlerImpl.class);
    }
}
